//
//  GetClientInfoH5Plugin.m
//  PCDBank
//
//  Created by 王俣 on 2018/9/8.
//  Copyright © 2018年 yt. All rights reserved.
//

#import "GetClientInfoH5Plugin.h"

#define USER_PhoneNumber  @"UserPhoneNumber"

@implementation GetClientInfoH5Plugin

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback{
    
    NSString *appVersion = [PCDUtil appVersion];
    
    NSString *clientInfo = [PCDUtil safeString:[PCDDevice deviceModel]];
    
    
    NSString *isPhoneX = @"0";
    if ([PCDUtil IsIphoneX]) {
        isPhoneX = @"1";
    }
    NSString *lastPhone = [PCDDataStorageMangerGet() cacheUDStringForKey:kUserMobilePhone];
    NSString *deviceId = [PCDUtil safeString:[PCDDevice uniqueIdentifier]];
    NSDictionary *dict = @{@"CLIENT_VER_NO":appVersion,
                           @"CLIENT_OS":@"I",
                           @"IDFV":[PCDUtil safeString:[self getIDFV]],
                           @"DEVICE_NAME":clientInfo,
                           @"IsIphoneX":isPhoneX,
                           @"DEVICE_ID":deviceId,
                           @"LastPhoneNumber":[PCDUtil safeString:lastPhone],
                           };
    
    NSDictionary *dictData = (NSDictionary *)data;
    NSString *strCallback = dictData[@"success"];
    
    evaluateJavaScriptOnMainThread(self, strCallback, [dict JSONRepresentation]);
    
}
-(NSString *)getIDFV{
   return [[UIDevice currentDevice] identifierForVendor].UUIDString;
}




@end
